<?php
declare(strict_types=1);

namespace App\Service;

use App\Utils\CustomUtils;
use Hyperf\Di\Annotation\Inject;
use App\Model\Dao\CurrencyCodeDao;
use App\Exception\XZXValidationException;
use App\Constants\XZXResponseCode;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Arr;
use Hyperf\Utils\Coroutine;
use App\Utils\DateUtils;


class CurrencyCodeService {
    /**
     * @Inject()
     * @var CurrencyCodeDao
     */
    private $CurrencyCodeDao;

    public function list (array $param) {

        $param = Arr::only($param, ['isBoc', 'code', 'name']);

        $total = $this->CurrencyCodeDao->getCount($param);
        $list  = $this->CurrencyCodeDao->getList($param);

        $list = array_map(function ($item) {
            return Arr::only($item, ['numCode', 'code', 'name', 'isBoc']);
        }, $list);

        $data = [
            'total' => $total,
            'list'  => $list,
        ];

        return CustomUtils::buildSuccess($data);
    }

}
